import { Table, Tag, Space } from 'antd';
import { history, connect } from 'umi';

const columns = [
  {
    title: '姓名',
    dataIndex: 'name',
    key: 'name',
  },
  {
    title: '年龄',
    dataIndex: 'age',
    key: 'age',
  },
  {
    title: '住址',
    dataIndex: 'address',
    key: 'address',
  },
];
const dataSource = [
  {
    key: '1',
    name: '胡彦斌',
    age: 32,
    address: '西湖区湖底公园1号',
  },
  {
    key: '2',
    name: '胡彦祖',
    age: 42,
    address: '西湖区湖底公园1号',
  },
];
const User = ({ data, get, query }) => {
  console.log('data', data);
  return (
    <h1>
      <Table columns={columns} dataSource={dataSource} />
      <button onClick={() => get({ author: 'songsikai' })}>点击我哦</button>
      <button onClick={() => query()}>点击搜索哦</button>
    </h1>
  );
};

const mapStateToProps = (paylod: object) => {
  return {
    data: paylod,
  };
};

export default connect(
  (store: any) => {
    const { user } = store;
    const { data } = user;
    return { data };
  },
  (dispatch: Function) => ({
    get: () => {
      dispatch({
        type: 'user/get',
      });
    },
    query: () => {
      dispatch({
        type: 'user/query',
      });
    },
  }),
)(User);
